#####
#
# Create Default Web Application for http://<portal>
#
####

## kill Main Install if Terminate = $true
if ($env:terminate -eq $true) {exit 0}

# Add Sharepoint pssnapin

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 

if( ( get-spwebapplication $env:farmurl -ea silentlycontinue) -ne $null )
{
	Write-Host -ForegroundColor Yellow "Web app $env:farmname already exist. Skipping Creation"
}
else {

	Write-Host  "Creating web app..."
	new-spwebapplication -ApplicationPool "$env:farmname Application Pool" -ApplicationPoolAccount $env:serviceacct -Name "$env:farmname" -Url "$env:farmurl" -DatabaseName "$env:DatabasePrefix_ContentDB_Default" -Path "E:\inetpub\vroots\$env:farmname" -port 80 
}